import unittest
import process_html as pro
from htmlParser import *
from document import *

class TestProcessHTML(unittest.TestCase):
    def testParseHTML(self):
        input_string = "<title>this is the title</title> this is pretty spectacular."
        new_doc = document([], 'awesome', 'html')
        x = pro.parseHTML(input_string, new_doc)
        self.assertEqual(new_doc.title, ['titl'])
        self.assertEqual(x, ['pretti', 'spectacular'])
     
    def testProcessBody(self):
        html_parser = htmlParser()
        html_parser.body = "this is pretty spectaculars."
        x = pro.processBody(html_parser)
        self.assertEqual(x, ['pretti', 'spectacular'])
    
    def testProcessLinks(self):
        html_parser = htmlParser()
        html_parser.links = ['amazon', 'google']
        new_doc = document([], 'awesome', 'html')
        pro.processLinks(new_doc, html_parser)
        self.assertEqual(new_doc.authors, ['amazon', 'google'])
     
    def testProcessTitle(self):
        html_parser = htmlParser()
        html_parser.title = "War and Peace"
        new_doc = document([], 'awesome', 'html')
        pro.processTitle(new_doc, html_parser)
        self.assertEqual(new_doc.title, ['war', 'peac'])        
               
if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestProcessHTML)
    unittest.TextTestRunner(verbosity=2).run(suite)